package com.zyf.ppx.presenter


import com.zyf.connotation.utils.RequestMap
import com.zyf.ppx.bean.Connotion
import com.zyf.ppx.utils.ServiceUtils
import com.zyf.ppx.view_interface.NetInterface
import com.zyf.rxjavaapp.webinterface.WebService
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import java.util.*

class ConnotationPresenter {
    var cursor = "0"
    private var netInterface:NetInterface<Connotion>?=null
    constructor(netInterface: NetInterface<Connotion>){
        this.netInterface = netInterface
    }
        // 推荐1 文字 11 视频4  游戏22 图片10
     fun getConnotation(type:String,feed_count:Int){
         var request = RequestMap.getMap()
         request["list_type"] = type
         request["feed_count"] = feed_count.toString()
         request["cursor"] = cursor
         var rticket = "" + Date().time
         cursor = rticket
         request["_rticket"] = rticket
         request["ts"] = rticket.substring(0,rticket.length-3)
        ServiceUtils.createService(WebService::class.java)
            .getConnotation(request)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe({
                if("success" == it.message){
                    netInterface?.result(it.data)
                }
            },{
                netInterface?.error(it.message)
            })
    }
}


